# Maintainer: Eric Belanger <eric@archlinux.org>
# Contributor: John Proctor <jproctor@prium.net>

pkgname=libxslt
pkgver=1.1.34
pkgrel=6
pkgdesc="XML stylesheet transformation library"
url="http://xmlsoft.org/XSLT/"
arch=(x86_64)
license=(custom)
depends=(libxml2 libgcrypt)
makedepends=(git docbook-xsl)
checkdepends=(docbook-xml python)
_commit=3653123f992db24cec417d12600f4c67388025e3  # tags/v1.1.34^0
source=("git+https://gitlab.gnome.org/GNOME/libxslt.git#commit=$_commit"
        0001-Make-generate-id-deterministic.patch
        0002-Fix-manpage.patch)
sha256sums=('SKIP'
            '80ffc45016b2c0b8edeb332ba587a8523ea5ed856229e7f531edd0af9742bab3'
            'd7dea109c91958e2231c06d9b841853855a666f93b001a1999beab42c3345203')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname

  # Fix build with libxml libxml2-2.9.12
  git cherry-pick -n 9ae2f94df1721e002941b40665efb762aefcea1a
  git cherry-pick -n 824657768aea2cce9c23e72ba8085cb5e44350c7
  git cherry-pick -n 77c26bad0433541f486b1e7ced44ca9979376908

  # Make xsltproc output reproducible for packages which use it to generate documentation
  patch -Np1 -i ../0001-Make-generate-id-deterministic.patch

  # Fix manpage whitespace and rebuild the manpage
  patch -Np1 -i ../0002-Fix-manpage.patch
  rm doc/xsltproc.1

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr --without-python --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set sw=2 et:
